home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: undergrad.math.uwaterloo.ca!sckettle
- From: sckettle@undergrad.math.uwaterloo.ca (Steve Kettle)
- Subject: Re: How to initialize array of objects using non-void constructor?
- Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
- Message-ID: <DpAoG2.nCn@undergrad.math.uwaterloo.ca>
- Date: Wed, 3 Apr 1996 16:28:50 GMT
- References: <4jbuo5$mcb@newshost.lanl.gov> <315C8F65.78D5@aai.arco.com> <315F5E13.799D1B33@alcyone.com>
- Nntp-Posting-Host: noether.math.uwaterloo.ca
- Organization: University of Waterloo
-
- In article <315F5E13.799D1B33@alcyone.com>,
- Erik Max Francis <max@alcyone.com> wrote:
- >Brian Leach wrote:
- >
- >> Liang Lu wrote:
- >> >
- >> > Example:
- >> >
- >> > class Table {
- >> > Table() ;
- >> > Table(int n) ;
- >> > ..
- >> > } ;
- >> >
- >> > Table object[10] ; // default constructor are used here
- >>
- >> Sorry Liang, it is not possible. The language does not allow for
- >> non-default
- >> constructors for arrays of objects.
- >
- >Nonsense; see Ellis & Stroustrup, 12.6.1. Using non-default constructors for
- >initializing an array is much the same as one would expect (using the example
- >above):
- >
- > Table object[3] = { object(1), object(1), object(2) };
- >
- >--
-
- But you can't for an array on the heap.
- --
-